const path=require("path");

//假设一个文件的存放路径
const pathStr1="/a/b/c/index.html";
const pathStr2="/NODE-JS/day1/test.txt";

//用path.extname()方法获取文件扩展名
const nameExt1=path.extname(pathStr1);
const nameExt2=path.extname(pathStr2);

console.log(nameExt1);
console.log("^^^^^^");
console.log(nameExt2);